package com.hzh.cusviewdemo.Adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.hzh.cusviewdemo.Bean.ClassData;
import com.hzh.cusviewdemo.R;

import java.util.List;

public class ClassAdapter extends RecyclerView.Adapter<ClassAdapter.MyHolder> {

    private List<ClassData> dataList;

    public ClassAdapter(List<ClassData> dataList) {
        this.dataList = dataList;
    }

    @NonNull
    @Override
    public ClassAdapter.MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_class, parent, false);
        return new MyHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ClassAdapter.MyHolder holder, int position) {
        holder.ic_name.setText(dataList.get(position).getTitle());
    }

    @Override
    public int getItemCount() {
        return dataList.size();
    }

    static class MyHolder extends RecyclerView.ViewHolder {

        private TextView ic_name;

        public MyHolder(@NonNull View itemView) {
            super(itemView);
            ic_name = itemView.findViewById(R.id.ic_name);
        }
    }
}
